package com.job.yangshida;

import java.util.Scanner;

/**
 * @author yang
 * @version 1.0
 * @since 2022-07-04 13:05:14
 */
public class GetVictory0702 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("输入游戏人数");
        int num=sc.nextInt();
        int victorynum=GetVictory0702.getNum(num);
        System.out.println("获胜的是"+victorynum);
    }

    public static int getNum(int num) {
        int [] person=new int[num];
        //给人编号
        for (int i=0;i<num;i++){
            person[i]=i+1;
        }
        while (person.length>3){
            int[] newPerson=new int[person.length-1];
            for (int j=3;j<person.length;j++){
                newPerson[j-3]=person[j];
            }
            newPerson[newPerson.length-2]=person[0];
            newPerson[newPerson.length-1]=person[1];
            person=newPerson;
        }
        return person[1];
    }
}
